import io
import os
from qwen_agent.agents import Assistant
llm_cfg = {
    # Use the model service provided by DashScope:
    #'model': 'qwen-max-latest',
    #'model_type': 'qwen_dashscope',
    # 'api_key': 'YOUR_DASHSCOPE_API_KEY',
    # It will use the `DASHSCOPE_API_KEY' environment variable if 'api_key' is not set here.

    # Use a model service compatible with the OpenAI API, such as vLLM or Ollama:
    # 'model': 'Qwen2.5-7B-Instruct',
    'model_server': 'http://192.168.10.3:8000/v1',  # base_url, also known as api_base
    'api_key': '1233456',

    # (Optional) LLM hyperparameters for generation:
    'generate_cfg': {
        'top_p': 0.8
    }
}


def retriever_func(query):
    docs = vector_store.similarity_search(query, k=3)
    return [doc.page_content for doc in docs]
# bot = Assistant(llm=llm_cfg,
#                 system_message=system_instruction,
#                 function_list=tools,
#                 files=files)
bot = Assistant(
    llm=llm_cfg,
    system_message=system_instruction,
    function_list=tools,
    retriever=retriever_func  # 替代 files
)